<template>
  <div class="box1">
    <div class="title">
      <p>男女比例</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="sex">
      <div class="man">
        <img src="../../images/man.png" alt="" />
      </div>
      <div class="woman">
        <img src="../../images/woman.png" alt="" />
      </div>
    </div>

    <div class="rate">
      <p>男士58%</p>
      <p>女士42%</p>
    </div>
    <div ref="charts" class="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

//获取节点
const charts = ref()

onMounted(() => {
  //获取echarts类的实例
  const mycharts = echarts.init(charts.value)

  //设置实例的配置项
  mycharts.setOption({
    //布局组件
    grid: {
      left: '60',
      right: '60'
    },

    //X轴组件
    xAxis: {
      show: false,
      min: 0,
      max: 100
    },
    //Y轴组件
    yAxis: {
      type: 'category',
      show: false
    },
    //系列组件：决定展示什么样的图形
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: 'blue',
          borderRadius: 20
        }
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: 20
        }
      }
    ]
  })
})
</script>

<style lang="scss" scoped>
.box1 {
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;

  .title {
    p {
      color: white;
      font-size: 20px;
    }
  }

  .sex {
    display: flex;
    justify-content: center;

    .man {
      margin: 25px 40px;
      width: 111px;
      height: 115px;
      background: url(../../images/man-bg.png) no-repeat;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .woman {
      margin: 25px 40px;
      width: 111px;
      height: 115px;
      background: url(../../images/woman-bg.png) no-repeat;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }

  .rate {
    display: flex;
    justify-content: space-between;
    color: white;
    margin: 3px 60px;
  }

  .charts {
    height: 50px;
  }
}
</style>
